home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / PScreateLockingUI.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  11.4 KB  |  426 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. // Copyright (C) 1997-1999 Alias|Wavefront,
  18. // a division of Silicon Graphics Limited.
  19. //
  20. // The information in this file is provided for the exclusive use of the
  21. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  22. // and incorporate this code into other products for purposes authorized
  23. // by the Alias|Wavefront license agreement, without fee.
  24. //
  25. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  26. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  27. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  28. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  29. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  30. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  31. // PERFORMANCE OF THIS SOFTWARE.
  32. //
  33. //
  34. //  Alias|Wavefront Script File
  35. //  MODIFY THIS AT YOUR OWN RISK
  36. //
  37. //  Creation Date:  Nov. 96
  38. //
  39. //
  40. // Description:
  41. //    This script creates a window that can be used to
  42. //    set the locked status of attributes on active objects.
  43. //
  44. //  Input Arguments:
  45. //      None.
  46. //
  47. //  Return Value:
  48. //      None.
  49. //
  50. //
  51.  
  52. global proc PSupdateLockingUI ( string $parent, string $selectedItem )
  53. //
  54. // Setup the two lists of attributes - those that
  55. // are locked, and those that aren't, so the user
  56. // can flip them from one side to the other.
  57. //
  58. {
  59.     setParent $parent;
  60.  
  61.     int $LOCKED_List_Limit, $NONLOCKED_List_Limit;
  62.     string $LOCKED_List[], $NONLOCKED_List[];
  63.  
  64.     $LOCKED_List = `listAttr  -m -l -s -v -r -w -c $selectedItem`;
  65.     $NONLOCKED_List = `listAttr -m -u -s -v -r -w -c $selectedItem`;
  66.     $LOCKED_List_Limit = size( $LOCKED_List );
  67.     $NONLOCKED_List_Limit = size( $NONLOCKED_List );
  68.  
  69.     $LOCKED_List = sort($LOCKED_List);
  70.     $NONLOCKED_List = sort($NONLOCKED_List);
  71.  
  72.     // Since listAttr is going to return the full attribute names
  73.     // we need, strip off any component parts of $selectedItem
  74.     // by tokenizing based on the "." character.
  75.     //
  76.     string $node, $buffer[];
  77.     tokenize( $selectedItem, ".", $buffer );
  78.     if( size( $buffer ) > 0 ) {
  79.         $node = $buffer[0];
  80.     } else {
  81.         $node = $selectedItem;
  82.     }
  83.  
  84.     // First clear, then refill the locked and 
  85.     // non-locked scroll lists
  86.     //
  87.  
  88.     textScrollList -e -m 0 LOCKED_List;
  89.     textScrollList -e -m 0 NONLOCKED_List;
  90.  
  91.     textScrollList -e -ra LOCKED_List;
  92.     textScrollList -e -ra NONLOCKED_List;
  93.  
  94.     int $i;
  95.     for ( $i=0; $i < $LOCKED_List_Limit; $i++ )
  96.     {
  97.         textScrollList -e -a $LOCKED_List[$i] LOCKED_List;
  98.     }
  99.  
  100.     for ( $i=0; $i < $NONLOCKED_List_Limit; $i++ )
  101.     {
  102.         int $isLocking;
  103.         string  $attrName = ( $node + "." + $NONLOCKED_List[$i] );
  104.  
  105.         if( !catch( $isLocking = `getAttr -l $attrName` )
  106.         &&( $isLocking == 0 ) )
  107.         {                    
  108.             textScrollList -e -a $NONLOCKED_List[$i] NONLOCKED_List;
  109.         }
  110.     }
  111.  
  112.     textScrollList -e -m 1 LOCKED_List;
  113.     textScrollList -e -m 1 NONLOCKED_List;
  114.  
  115.     // Hook up the buttons to the right object
  116.     //
  117.     button -e 
  118.         -c ( "PS_unlockAttributes " + $parent + " " + $selectedItem )
  119.         NONLOCKED_Button;
  120.     button -e
  121.         -c ( "PS_lockAttributes " + $parent + " " + $selectedItem )
  122.         LOCKED_Button;
  123.  
  124.     // Dim the lock and unlock buttons.  They will be undimmed when
  125.     // the user clicks on either list
  126.     //
  127.     disable LOCKED_Button;
  128.     disable NONLOCKED_Button;
  129. }
  130.  
  131. global proc PS_lockAttributes ( string $parent, string $selectedItem )
  132. //
  133. // Move items selected in the non-locked list
  134. // to the locked list...
  135. //
  136. {
  137.     setParent $parent;
  138.  
  139.     int $selectedAttrsSize;
  140.     string $selectedAttrs[];
  141.  
  142.     $selectedAttrs = `textScrollList -q -si NONLOCKED_List`;
  143.     $selectedAttrsSize = size( $selectedAttrs );
  144.  
  145.     // Since listAttr is going to return the full attribute names
  146.     // we need, strip off any component parts of $selectedItem
  147.     // by tokenizing based on the "." character.
  148.     //
  149.     string $node, $buffer[];
  150.     tokenize( $selectedItem, ".", $buffer );
  151.     if( size( $buffer ) > 0 ) {
  152.         $node = $buffer[0];
  153.     } else {
  154.         $node = $selectedItem;
  155.     }
  156.  
  157.     // see if the ALL option is engaged
  158.     //
  159.     int $changeAll = `checkBox -q -v CC_LOCKALL_Box`;
  160.  
  161.     if ( $changeAll ){
  162.         // get the node type of the current node
  163.         //
  164.         string $baseType = `nodeType $selectedItem`;
  165.  
  166.         // get a list of all selected nodes
  167.         //
  168.         string $allNodes[] = `selectedNodes`;
  169.  
  170.         // for each node that matches type, set the locked state
  171.         // of each attribute in the non-locked list
  172.         //
  173.         int $limit = `size($allNodes)`;
  174.         string $thisNode;
  175.         int $index;
  176.         for ( $index=0; $index<$limit; $index++ ){
  177.             $thisNode = $allNodes[$index];
  178.             if ( `nodeType $thisNode` == $baseType ){
  179.                 int $i;
  180.                 for ( $i=0; $i<$selectedAttrsSize; $i++ ){
  181.                     setAttr -l on ( $thisNode + "." + $selectedAttrs[$i] );
  182.                 }
  183.             }
  184.         }
  185.     } else {  // only change the selected node
  186.  
  187.         int $i;
  188.         for( $i=0; $i < $selectedAttrsSize; $i++ )
  189.         {
  190.             setAttr -l on ( $node + "." + $selectedAttrs[$i] );
  191.         }
  192.     }
  193.  
  194.     // Update the window
  195.     //
  196.     PSupdateLockingUI $parent $selectedItem;
  197. }
  198.  
  199.  
  200. global proc PS_unlockAttributes ( string $parent, string $selectedItem )
  201. //
  202. // Move items selected in the locked list
  203. // to the non-locked list...
  204. //
  205. {
  206.     setParent $parent;
  207.     
  208.     int $selectedAttrsSize;
  209.     string $selectedAttrs[];
  210.  
  211.     $selectedAttrs = `textScrollList -q -si LOCKED_List`;
  212.     $selectedAttrsSize = size( $selectedAttrs );
  213.  
  214.     // Since listAttr is going to return the full attribute names
  215.     // we need, strip off any component parts of $selectedItem
  216.     // by tokenizing based on the "." character.
  217.     //
  218.     string $node, $buffer[];
  219.     tokenize( $selectedItem, ".", $buffer );
  220.     if( size( $buffer ) > 0 ) {
  221.         $node = $buffer[0];
  222.     } else {
  223.         $node = $selectedItem;
  224.     }
  225.  
  226.     // see if the ALL option is engaged
  227.     //
  228.     int $changeAll = `checkBox -q -v CC_LOCKALL_Box`;
  229.  
  230.     if ( $changeAll ){
  231.         // get the node type of the current node
  232.         //
  233.         string $baseType = `nodeType $selectedItem`;
  234.  
  235.         // get a list of all selected nodes
  236.         //
  237.         string $allNodes[] = `selectedNodes`;
  238.  
  239.         // for each node that matches type, set the locked state
  240.         // of each attribute in the non-locked list
  241.         //
  242.         int $limit = `size($allNodes)`;
  243.         string $thisNode;
  244.         int $index;
  245.         for ( $index=0; $index<$limit; $index++ ){
  246.             $thisNode = $allNodes[$index];
  247.             if ( `nodeType $thisNode` == $baseType ){
  248.                 int $i;
  249.                 for ( $i=0; $i<$selectedAttrsSize; $i++ ){
  250.                     string $pAttr[] = `attributeQuery -lp -n $thisNode $selectedAttrs[$i]`;
  251.                     if (size($pAttr) > 0) {
  252.                         int $pLock;
  253.                         $pLock = `getAttr -l ( $thisNode + "." + $pAttr[0] )`;
  254.                         if ($pLock == 1) {
  255.                             // If the parent is locked.
  256.                             //        Unlock the parent and 
  257.                             //        Lock the rest of the children
  258.                             //
  259.                             setAttr  -l off ( $thisNode + "." + $pAttr[0] );
  260.                             string $cAttr[] = `attributeQuery -lc -n $thisNode $pAttr[0]`;
  261.                             int $cCount = size($cAttr);
  262.                             for ( $c=0; $c<$cCount; $c++ ){
  263.                                 setAttr -l 1 ( $thisNode + "." + $cAttr[$c] );
  264.                             }
  265.                         }
  266.                     }
  267.                     setAttr -l off ( $thisNode + "." + $selectedAttrs[$i] );
  268.                 }
  269.             }
  270.         }
  271.     } else {  // only change the selected node
  272.         int $i;
  273.         for( $i=0; $i < $selectedAttrsSize; $i++ )
  274.         {
  275.             string $pAttr[] = `attributeQuery -lp -n $node $selectedAttrs[$i]`;
  276.             if (size($pAttr) > 0) {
  277.                 int $pLock;
  278.                 $pLock = `getAttr -l ( $node + "." + $pAttr[0] )`;
  279.                 if ($pLock == 1) {
  280.                     // If the parent is locked.
  281.                     //        Unlock the parent and 
  282.                     //        Lock the rest of the children
  283.                     //
  284.                     setAttr  -l off ( $node + "." + $pAttr[0] );
  285.                     string $cAttr[] = `attributeQuery -lc -n $node $pAttr[0]`;
  286.                     int $cCount = size($cAttr);
  287.                     for ( $c=0; $c<$cCount; $c++ ){
  288.                         setAttr -l 1 ( $node + "." + $cAttr[$c] );
  289.                     }
  290.                 }
  291.             }
  292.             setAttr -l off ( $node + "." + $selectedAttrs[$i] );    
  293.         }
  294.     }
  295.  
  296.     // Update the window
  297.     //
  298.     PSupdateLockingUI $parent $selectedItem;
  299. }
  300.  
  301.  
  302. global proc PScreateLockingUI( string $parent, string $node )
  303. //
  304. // Sets up a UI that shows all the DAG and
  305. // Shape nodes in the system, so that the 
  306. // user can set the locked attributes for
  307. // them.
  308. //
  309. {
  310.     setParent $parent;
  311.  
  312.     string $myContainer = `formLayout containerForm`;
  313.  
  314.     text -l "Locked" LOCKED_Text;
  315.  
  316.     // Label the non-locked area
  317.     //
  318.     text -l "Non Locked" NONLOCKED_Text;
  319.  
  320.     // Create the Move to non-locked button
  321.     //
  322.     string $nkButton = `button -l "Move >>" 
  323.         -c ( "PS_unlockAttributes " + $parent + " " + $node )
  324.         -h 26
  325.         NONLOCKED_Button`;
  326.  
  327.     // Create the Move to locked button
  328.     //
  329.     string $kButton = `button -l "<< Move" 
  330.         -c ( "PS_lockAttributes " + $parent + " " + $node )
  331.         -h 26
  332.         LOCKED_Button`;
  333.  
  334.     // Create the cancel/close button
  335.     //
  336.     button -l "Close" -h 26 -c "deleteUI LockingKeyable" CLOSE_Button;
  337.  
  338.     // Create the ALL checkbox
  339.     //
  340.     if ( !`optionVar -exists CClockAllSame` ){
  341.         optionVar -intValue CClockAllSame 1;
  342.     }
  343.     checkBox
  344.         -l "Change all selected objects of the same type"
  345.         -v `optionVar -q CClockAllSame`
  346.         -cc "optionVar -intValue CClockAllSame #1"
  347.         CC_LOCKALL_Box;
  348.  
  349.     // Create the locked scroll list
  350.     //
  351.     textScrollList
  352.         -ams 1
  353.         -h 150
  354.         -sc ("disable LOCKED_Button; disable -v false " + $nkButton + ";textScrollList -e -da NONLOCKED_List" )
  355.         LOCKED_List;
  356.  
  357.     // Create the non-locked scroll list
  358.     //
  359.     textScrollList
  360.         -ams 1
  361.         -h 150
  362.         -sc ("disable NONLOCKED_Button; disable -v false " + $kButton + ";textScrollList -e -da LOCKED_List" )
  363.         NONLOCKED_List;
  364.  
  365.     separator -style "in" -hr true LOCKED_Sep;
  366.  
  367.     // Edit the form attachments
  368.     //
  369.  
  370.     formLayout -edit
  371.         -af LOCKED_Text top 10 
  372.         -af LOCKED_Text left 10
  373.         -ap LOCKED_Text right 10 50
  374.         -an LOCKED_Text bottom
  375.  
  376.         -af NONLOCKED_Text top 10
  377.         -ap NONLOCKED_Text left 10 50
  378.         -af NONLOCKED_Text right 10 
  379.         -an NONLOCKED_Text bottom
  380.  
  381.         -af LOCKED_List top 30
  382.         -af LOCKED_List left 10
  383.         -ap LOCKED_List right 0 50
  384.         -ac LOCKED_List bottom 10 LOCKED_Sep
  385.  
  386.         -af NONLOCKED_List top 30
  387.         -ap NONLOCKED_List left 0 50
  388.         -af NONLOCKED_List right 10
  389.         -ac NONLOCKED_List bottom 10 LOCKED_Sep
  390.  
  391.         -an LOCKED_Sep top
  392.         -af LOCKED_Sep left 0
  393.         -af LOCKED_Sep right 0
  394.         -af LOCKED_Sep bottom 60
  395.  
  396.         -an CC_LOCKALL_Box top
  397.         -af CC_LOCKALL_Box left 15
  398.         -af CC_LOCKALL_Box bottom 35
  399.         -an CC_LOCKALL_Box right
  400.  
  401.         -an CLOSE_Button top
  402.         -ap CLOSE_Button right 2 66
  403.         -ap CLOSE_Button left 2 33
  404.         -af CLOSE_Button bottom 5
  405.  
  406.         -an NONLOCKED_Button top
  407.         -ap NONLOCKED_Button right 2 33
  408.         -af NONLOCKED_Button left 5
  409.         -af NONLOCKED_Button bottom 5
  410.  
  411.         -an LOCKED_Button top
  412.         -ap LOCKED_Button left 2 66
  413.         -af LOCKED_Button right 5
  414.         -af LOCKED_Button bottom 5
  415.  
  416.         $myContainer;
  417.  
  418.  
  419.     // Fill the scroll lists
  420.     // with the selected object's attributes
  421.     //
  422.  
  423.     PSupdateLockingUI $parent $node;
  424.     showWindow;
  425. }
  426.